#-*-coding:utf-8-*-
import hou
class ObjectsAndGeometry(object):
    def __init__(self):
        super(ObjectsAndGeometry,self).__init__()


    def setPreferences_HighlighObjectSelectionsInViewer(self,bool):
        if bool == True:
            hou.setPreference('objects.highlight.val','1')
            # print('1')
        else:
            hou.setPreference('objects.highlight.val','0')
            # print('0')

    def getPreferences_HighlighObjectSelectionsInViewer(self):
        return hou.getPreference('objects.highlight.val')
        # print('getPreferences_HighlighObjectSelectionsInViewer')







    def setPreferences_AutomaticParameterFolderFlippingWhenObjectsArePickedInViewer(self,bool):
        if bool == True:
            hou.setPreference('objects.folderflipping.val','1')
            # print('1')
        else:
            hou.setPreference('objects.folderflipping.val','0')
            # print('0')

    def getPreferences_AutomaticParameterFolderFlippingWhenObjectsArePickedInViewer(self):
        return hou.getPreference('objects.folderflipping.val')
        # print('getAutomaticParameterFolderFlippingWhenObjectsArePickedInViewer')



    def setPreferences_DefaultGemetryDisplay(self,displayNum):
        '''
        :param displayNum: 0 - Show Display Operator,
        1 - Show Current Operator
        :return:
        '''
        hou.setPreference('tools.sopviewmode.val', str(displayNum))
        # print('setDefaultGemetryDisplay')


    def getPreferences_DefaultGemetryDisplay(self):
        return  hou.getPreference('tools.sopviewmode.val')
        # print('getDefaultGemetryDisplay')



    def setPreferences_DefaultContextCreation(self,contextNum):
        '''
        :param contextNum: 0 - Create at Object Level,
        1 - Create in Context
        :return:
        '''
        hou.setPreference('tools.createincontext.val', str(contextNum))
        # print('setDefaultContextCreation')
    def getPreferences_DefaultContextCreation(self):
        return hou.getPreference('tools.createincontext.val')
        # print('getDefaultContextCreation')


    def setPreferences_UseExistingSelectionToCompleteAction(self,bool):
        if bool == True:
            hou.setPreference('selector.useexisting.val','1')
            # print('1')
        else:
            hou.setPreference('selector.useexisting.val','0')
            # print('0')

    def getPreferences_UseExistingSelectionToCompleteAction(self):
        return hou.getPreference('selector.useexisting.val')
        # print('getUseExistingSelectionToCompleteAction')


    def setPreferences_SecureSelectionOnByDefault(self,bool):
        if bool == True:
            hou.setPreference('tools.secure.val','1')
            # print('1')
        else:
            hou.setPreference('tools.secure.val','0')
            # print('0')

    def getPreferences_SecureSelectionOnByDefault(self):
        return hou.getPreference('tools.secure.val')
        # print('getSecureSelectionOnByDefault')


    def setPreferences_AreaSelectVisibleGeometryOnByDefault(self,bool):

        if bool == True:
            hou.setPreference('selector.areaselvisible.val','1')
            # print('1')
        else:
            hou.setPreference('selector.areaselvisible.val','0')
            # print('0')

    def getPreferences_AreaSelectVisibleGeometryOnByDefault(self):
        return hou.getPreference('selector.areaselvisible.val')
        # print('getAreaSelectVisibleGeometryOnByDefault')


    def setPreferences_CreateFullLoopSelectioonsThroughAnyTopology(self,bool):
        if bool == True:
            hou.setPreference('selector.fullloops.val','1')
            # print('1')
        else:
            hou.setPreference('selector.fullloops.val','0')
            # print('0')

    def getPreferences_CreateFullLoopSelectioonsThroughAnyTopology(self):
        return hou.getPreference('selector.fullloops.val')
        # print('getCreateFullLoopSelectioonsThroughAnyTopology')


    def setPreferences_SelectEntireDigitalAssetOnByDefault(self,bool):
        if bool == True:
            hou.setPreference('objects.selectsubnet.val','1')
            # print('1')
        else:
            hou.setPreference('objects.selectsubnet.val','0')
            # print('0')

    def getPreferences_SelectEntireDigitalAssetOnByDefault(self):
        return hou.getPreference('objects.selectsubnet.val')
        # print('getSelectEntireDigitalAssetOnByDefault')


    def setPreferences_HighlightSelectedGeometryInViewport(self,bool):
        if bool == True:
            hou.setPreference('network.autohighlight.val','1')
            # print('1')
        else:
            hou.setPreference('network.autohighlight.val','0')
            # print('0')


    def getPreferences_HighlightSelectedGeometryInViewport(self):
        return hou.getPreference('network.autohighlight.val')
        # print('getHighlightSelectedGeometryInViewport')



    def setPreferences_PopupMenuSelection(self,bool):
        if bool == True:
            hou.setPreference('objects.pickingmenu.val', '1')
            # print('1')
        else:
            hou.setPreference('objects.pickingmenu.val', '0')
            # print('0')

    def getPreferences_PopupMenuSelection(self):
        return hou.getPreference('objects.pickingmenu.val')
        # print('getPopupMenuSelection')


    def setPreferences_KeepPositionWhenParenting(self,posNum):
        '''
        :param posNum: 0 - Never , 1 - Always, 2 - Use Object Flag
        :return:
        '''
        hou.setPreference('objects.keepPos.val',str(posNum))
        # print('setKeepPositionWhenParenting')

    def getPreferences_KeepPositionWhenParenting(self):
        return hou.getPreference('objects.keepPos.val')
        # print('getKeepPositionWhenParenting')



    def setPreferences_ChildCompensation(self,compensationNum):
        '''
        :param compensationNum: 0 - Never, 1 - Always, 2 - Use Object Flag
        :return:
        '''

        hou.setPreference('objects.keepPosMoving.val', str(compensationNum))
        # print('setChildCompensation')

    def getPreferences_ChildCompensation(self):
        return hou.getPreference('objects.keepPosMoving.val')
        # print('getChildCompensation')



    def setPreferences_BoneKinematicOverride(self,overrideNum):
        '''
        :param overrideNum: 0 - None , 1 - IK Rest Pose ,
        2 - Capture Pose
        :return:
        '''

        hou.setPreference('objects.kinoverride.val', str(overrideNum))
        # print('setBoneKinematicOverride')

    def getPreferences_BoneKinematicOverride(self):
        return hou.getPreference('objects.kinoverride.val')
        # print('getBoneKinematicOverride')


    def setPreferences_ReadOnlyPreTransforms(self,bool):
        if bool == True:
            hou.setPreference('objects.overwriteanim.val','1')
            # print('1')
        else:
            hou.setPreference('objects.overwriteanim.val','0')
            # print('0')

    def getPreferences_ReadOnlyPreTransforms(self):
        return hou.getPreference('objects.overwriteanim.val')
        # print('getReadOnlyPreTransforms')




    def setSopCache_SopCachingControls_CullLevel(self,value):

        hou.setPreference('sopcache.level.val', str(value))
        # print('setSopCache_SopCachingControls_CullLevel')


    def getSopCache_SopCachingControls_CullLevel(self):
        return hou.getPreference('sopcache.level.val')
        # print('getSopCache_SopCachingControls_CullLevel')



    def setSopCache_SopCachingControls_MemoryLimit(self,value):
        hou.setPreference('sopcache.memorylimit.val',str(value))
        # print('setSopCache_SopCachingControls_MemoryLimit')




    def getSopCache_SopCachingControls_MemoryLimit(self):
        hou.getPreference('sopcache.memorylimit.val')
        # print('getSopCache_SopCachingControls_MemoryLimit')



    def setSopCache_ManualOverrides_Unloading(self,overrideNum):
        '''
        :param overrideNum:0 - Never, 1 - Flag , 2 - Always
        :return:
        '''
        if overrideNum == 0 or overrideNum=='Never':
            hou.setPreference('sopcache.unload.val','Never')
            # print('Never')

        elif overrideNum == 1 or overrideNum=='Flag':
            hou.setPreference('sopcache.unload.val','Flag')
            # print('Flag')

        elif overrideNum == 2 or overrideNum=='Always':
            hou.setPreference('sopcache.unload.val','Always')
            # print('Always')


    def getSopCache_ManualOverrides_Unloading(self):
        return  hou.getPreference('sopcache.unload.val')
        # print('getSopCache_ManualOverrides_Unloading')


    def setSopCache_ManualOverrides_Memory(self,memoryNum):
        '''
        :param memoryNum: 0 - Never , 1 - Always
        :return:
        '''
        if memoryNum == 0 or memoryNum=='Never':
            hou.setPreference('sopcache.memory.val','Never')
            # print('Never')

        elif memoryNum == 1 or memoryNum=='Always':
            hou.setPreference('sopcache.memory.val','Always')
            # print('Always')

    def getSopCache_ManualOverrides_Memory(self):
        return hou.getPreference('sopcache.memory.val')
        # print('getSopCache_ManualOverrides_Memory')




    def setObjCache_ObjCachingControls_MemoryLimit(self,value):
        hou.setPreference('objcache.memorylimit.val',str(value))
        # print('setObjCache_ObjCachingControls_MemoryLimit')

    def getObjCache_ObjCachingControls_MemoryLimit(self):
        return hou.getPreference('objcache.memorylimit.val')
        # print('getObjCache_ObjCachingControls_MemoryLimit')


    def ObjCache_ClearCache(self):
        hou.setPreference('objcache.clear.val', '1')
        # print('ObjCache_ClearCache')